package com.jiazaibendi.lottery.dao.mapper;

import com.jiazaibendi.lottery.dao.domain.WinRecordVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * description
 *
 * @author echo_kai
 * @version 1.0
 * @date 2021/08/07
 */
@Mapper
public interface WinRecordExtMapper {

    @Select("select count(id) from win_record where scheme_id = #{schemeId}")
    long queryAllJoinPeopleNumber(@Param("schemeId") long schemeId);

    @Select("select count(id) from win_record where scheme_id = #{schemeId} and prize_id != 0")
    long queryGainPrizePeopleNumber(@Param("schemeId") long schemeId);

    @Select("SELECT w.*,p.`name` as prize_name FROM `win_record` AS w LEFT JOIN prize p ON w.prize_id = p.id WHERE w.user_id = #{userId} AND w.scheme_id = #{schemeId}")
    List<WinRecordVo> selectPrizeList(@Param("userId") long userId,@Param("schemeId") long schemeId);
}